<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
 <%@ taglib prefix="s" uri="/struts-tags" %>
  <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<sj:head jqueryui="true"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">

//document.getElementById("hiddebButton").style.display="none";
//document.getElementById("hiddebButtonYard").style.display="none"; 

function fnCreateSection(){
	document.forms["sectionForm"].action = 'manageSection';
	document.forms["sectionForm"].submit();
}
</script>
</head>
<body>
<sj:div id="sectionDiv" cssClass="maincontent" indicator="indicator">
	
<s:form name = "sectionForm" theme="simple" id = "sectionForm" method="post" enctype="multipart/form-data">
<s:actionmessage/>
<table>
<tr>
<td width="10%">Select OEM :</td>
<td width="20%">
<s:select id = "oemType" name="oemType" list="oemList" listKey="oemId"
						listValue="oemName" headerKey="0" headerValue="Select OEM"
						onchange="$.publish('oemSelectedTopic')" >
						</s:select>
						<s:url var="populateYardUrl" action="ajaxAllocateYard" ></s:url>
		
			<sj:div id = "hiddebButtonYard" cssStyle="display:none;">
				<sj:submit  formIds="sectionForm"  href = "%{populateYardUrl}" listenTopics="oemSelectedTopic" targets="sectionDiv"></sj:submit>
			</sj:div>
</td>
<td width="10%">
		Select Yard :
		</td> 
		<td width="20%">
		<s:select label="Select Yard" headerKey="-1"
			headerValue="Select Yard" list="listYard" listKey="id"
			listValue="name" name="selectedYardId" onchange="$.publish('submitSectionTopic')" />

			<s:url var="populateSectionUrl" action="populateSection" ></s:url>
		
			<sj:div id = "hiddebButton" cssStyle="display:none;">
				<sj:submit  formIds="sectionForm"  href = "%{populateSectionUrl}" listenTopics="submitSectionTopic" targets="sectionDiv"></sj:submit>
			</sj:div>
		</td>
		<td width="65%"></td>
		<td align="right">
		<s:url var="populateSectionUrl" action="manageSection" escapeAmp="false">
		 <s:param name="yardId" value="%{selectedYardId}"/>
		  <s:param name="oemId" value="%{oemType}"/></s:url>
			<sj:submit name= "Clink" href="%{populateSectionUrl}"  targets="sectionDiv" formIds="sectionForm" label="Create Section" value="Create Section" cssClass="btnbg" disabled="%{isYardSelected}"></sj:submit>
		</td>
		<!--<td>
		<s:a  href="exportToExcel.action" disabled="%{isYardSelected}" value="Export" name="Export" label="Export">Export Sections</s:a>
		</td>
		-->
	</tr>
	<!--<s:if test = "%{isYardSelected}">
	<tr>
		<td>
   	 		<s:file name="sectionUploadFile" label="Sections" theme="simple" value="Section File" />
   	 	</td>
   	 	<td>
    		<sj:submit href = "sectionUpload.action" value="UploadSection" name = "UploadSection" formIds="sectionForm" targets="sectionDiv" />
    	</td>	
</tr>
</s:if>
--></table>


  <table border="1" width="100%" class="gridtableresult">
  <tr bgcolor="#038040" >
  <th>
  Section Name
  </th>
  <th>
  Permanent
 
  </th>
  <th>
  Active

  </th>
  <th>
  Capacity
 
  </th>

 <s:iterator value="listSections" status="status">
  <tr >
  <td>
  <s:url action="manageSection" id="secName" escapeAmp="false">
   <s:param name="yardId" value="%{selectedYardId}"/>
   <s:param name="sectionId" value="%{sectionId}"/>
   <s:param name="oemId" value="%{oemType}"/>
  </s:url>
  
  <sj:a href="%{secName}" targets="sectionDiv" formIds="sectionForm"><s:property value="sectionName"/></sj:a>
 
    </td>
  <td>
  <s:checkbox  name= "listSections.permanent" value ='%{permanent}' ></s:checkbox>
  </td>
  <td>
  <s:checkbox  name= "listSections.active"   value ='%{active}' ></s:checkbox>
  </td>
  <td>
  <s:textfield name= "listSections.capacity" value ='%{capacity}' readonly="%{isYardSelected}"></s:textfield>
  </td>
  <td>
  <!--<button value="Edit" name= "Clink" onclick="fnCallEditSection()">Edit Section</button>
  <button value="Edit" name= "Clink" onclick="fnShowParkingSlots()">Show Parking Slots</button>
  --></td>
  </tr>
  </s:iterator>
  
  

  
  </table>


</s:form>
</sj:div>
</body>
</html>